import axios from "axios";

const scmsBaseUrl= "http://localhost:8082";
const scmsRequest={
    loadScms(scms,callBack){
        let url = scmsBaseUrl + "/scms/list?";
        if(scms){
            if(scms.scmsEncode){
                url += "&scmsEncode=" + scms.scmsEncode;
            }
            if(scms.scmsName){
                url += "&scmsName=" + scms.scmsName;
            }
            if(scms.scmsType){
                url += "&scmsType=" + scms.scmsType;
            }
            if(scms.scmsStatus){
                url += "&scmsStatus=" + scms.scmsStatus;
            }
        }
        axios.get(url)
            .then(res=>{
                callBack(res.data);
            })
    },
    insert(scms,callBack){
        let url = scmsBaseUrl + "/scms/insert";
        axios.post(url,scms)
            .then(res=>{
                callBack(res.data);
            })
    },
    update(scms,callBack){
        let url  = scmsBaseUrl + "/scms/update";
        axios.put(url,scms)
            .then(res=>{
                callBack(res.data);
            })
    },
    selectById(scmsId,callBack){
        let url = scmsBaseUrl + "/scms/selectById?scmsId=" + scmsId;
        axios.get(url)
            .then(res=>{
                callBack(res.data);
            })
    },
    delete(scmsId,callBack){
        let url = scmsBaseUrl + "/scms/delete?scmsId=" + scmsId;
        axios.delete(url)
            .then(res=>{
                callBack(res.data);
            })
    }
}
export default scmsRequest;